#include <iostream>

using namespace std;

class Test
{
public:

    Test(int a, int b) : m_a(a), m_b(b)
    {
        
    }
    
    int add() // int add(Test *this)
    {
        //this->m_a;
        return m_a + m_b; //this->m_a + this->m_b;
    }

    int sub()
    {
        return m_a - m_b;
    }

    int print(int a, int b) // print(Test *this, int a, int b)
    {

    }

    int m_a;
    int m_b;
};


int main(int argc, char **argv)
{
    
    //指向类的成员变量的指针

    int Test::*p = &Test::m_b;   //&t.m_a: t对象中m_a成员变量的地址 --- 成员变量的指针来保存
    cout << p << endl; //4
    cout << &Test::m_a << endl;
    
    Test t(5,6);
    Test t1(5,6);

    cout << t.*p << endl; //t &t:0x1000  + 4

    int *pa = &t.m_a;
    cout << &t.m_a << endl;


    //指向类的成员函数的指针
    cout << &Test::add << endl;
    
    t.add(); //t.add(&t)
    t.print(5,6); //t.print(&t, 5, 6);
    t1.add(); // t.add(&t1);
    
    
    return 0;
}